#ifndef __ENP_LISTEN_H__
#define __ENP_LISTEN_H__

#include "enpdef.h"

class CEnpCtrl;
class CEnpListen: public CTEpollObject<CEnpCtrl>
{
protected:
    friend class CEnpCtrl;

    CEnpCtrl*   m_pstOwner;
    CTSocket    m_stSocket;
    CEnpListenInfo  m_stListenInfo;
    unsigned int    m_uiCreateTime;
    unsigned int    m_uiLastTime;

public:
    CEnpListen() :
        m_stSocket(PF_INET, SOCK_STREAM, false)
    {
    }

    virtual ~CEnpListen()
    {
        Unregister(); // 先Unregister从epoll注销, 然后再关闭socket
    }

    int Init(CEnpCtrl& stOwner, const CEnpListenInfo& stListenInfo);

	const CEnpListenInfo& GetListenInfo() const
	{
		return m_stListenInfo;
	}
};

#endif //__ENP_LISTEN_H__
